package com.sprometheus.event;

import com.sprometheus.core.pojo.GlobalExceptionBO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * @author 风白羽
 * @date 2024/9/5 下午4:56
 */
@Component
public class GlobalExpEventPublisher {

    private static final Logger logger = LoggerFactory.getLogger(GlobalExpEventPublisher.class);
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    public void publishCustomEvent(final GlobalExceptionBO message) {
        logger.info("开始发布消息，生产者...");
        GlobalExpEvent globalExpEvent = new GlobalExpEvent(this, message);
        applicationEventPublisher.publishEvent(globalExpEvent);
    }
}
